package com.nw.dsl4j.runtime.parser;

import org.antlr.runtime.Lexer;
import org.antlr.runtime.Parser;


public class Dsl4jParserImpl<P> extends AbstractReflectionDsl4jParserImpl<P> {

	protected Dsl4jParserImpl(Class<?> c) {
		this(c, c);
	}

	public Dsl4jParserImpl(Class<?> dslClass, Class<?> classToParse) {
		this(dslClass, classToParse, null);
	}

	@SuppressWarnings("unchecked")
	public Dsl4jParserImpl(Class<?> dslClass, Class<?> classToParse, Dsl4jParserContext parserContext) {
		super(dslClass, classToParse, parserContext);
		try {
			lexerClazz = (Class<? extends Lexer>) Class.forName(getLexerClassName());
			parserClazz = (Class<? extends Parser>) Class.forName(getParserClassName());
		} catch (Exception e) {
			throw new RuntimeException("Cannot instantiate lexer/parser classes" + e.getMessage(), e);
		}
	}
}
